﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _71重写
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            Animal dog = new Dog();
            dog.Say();
            Animal cat = new Cat();
            cat.Say();
        }
    }
    internal class Animal
    {
        public virtual void Say() //使用virtual标记这个方法可以被子类重写
        {
            Console.WriteLine("叫");
        }
    }

    internal class Dog : Animal
    {
        public override void Say()
        {
            base.Say();//可有可无,如果需要保留父类原有的功能就留着
            Console.WriteLine("旺旺");
        }
    }

    internal class Cat : Animal
    {
        public override void Say()
        {
            base.Say();
            Console.WriteLine("喵喵");
        }
    }
}